<%--
  Created by IntelliJ IDEA.
  User: 刘科
  Date: 2020/12/17
  Time: 20:33
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>华鑫农业信息管理系统</title>
    <link rel="stylesheet" type="text/css" href="../style/css.css">
    <link href="http://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <link href="../style/search.css" rel="stylesheet">
    <link rel="icon" href="../images/tubiao.ico" type="image/ico">
    <script language="javascript" type="text/javascript" src="../js/jquery1.4.min.js"></script>
    <script language="javascript" type="text/javascript" src="../js/jquery.jslider.js"></script>
    <!-- Place favicon.ico in the root directory -->
    <link rel="shortcut icon" type="image/x-icon" href="../img/favicon.ico">
    <!-- all CSS hear -->
    <link rel="stylesheet" href="../grzxcss/bootstrap.min.css">
    <link rel="stylesheet" href="../grzxcss/font-awesome.min.css">
    <link rel="stylesheet" href="../grzxcss/ionicons.min.css">
    <link rel="stylesheet" href="../grzxcss/animate.css">
    <link rel="stylesheet" href="../grzxcss/nice-select.css">
    <link rel="stylesheet" href="../grzxcss/slick.min.css">
    <link rel="stylesheet" href="../grzxcss/jquery-ui.css">
    <link rel="stylesheet" href="../grzxcss/owl.carousel.min.css">
    <link rel="stylesheet" href="../grzxcss/mainmenu.css">
    <!-- Style CSS hear -->
    <link rel="stylesheet" href="../grzxcss/style.css">
    <link rel="stylesheet" href="../grzxcss/responsive.css">
    <script src="../grzxjs/vendor/modernizr-2.8.3.min.js"></script>
    <!-- jquery -->
    <script src="../grzxjs/vendor/jquery-1.12.4.min.js"></script>
    <!-- main JS -->
    <script src="../grzxjs/main.js"></script>
    <script src="../js/myScript/app.js"></script>
</head>
<body>


<!--[if lt IE 8]>
<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade
    your browser</a> to improve your experience. Thanks</p>
<![endif]-->
<!-- Add your application content here -->

<div class="main-wrapper my-account-page">
    <jsp:include page="top.jsp"/>
    <!-- main-content-warpper start -->
    <div class="main-content-warpper pt-80">
        <div class="container">
            <div class="account-dashboard">
                <div class="dashboard-upper-info">
                </div>
                <div class="row">
                    <div class="col-md-12 col-lg-2">
                        <!-- Nav tabs -->
                        <ul class="nav flex-column dashboard-list" role="tablist">
                            <!--                            <li><a class="nav-link active" data-toggle="tab" href="#dashboard">Dashboard</a></li>-->
                            <li><a class="nav-link" data-toggle="tab" href="#orders" onclick="clickQueryOrder()">订单</a></li>
                            <li><a class="nav-link" onclick="pserLogout()">注销</a></li>
                        </ul>
                    </div>
                    <div class="col-md-12 col-lg-10">
                        <!-- Tab panes -->
                        <div class="tab-content dashboard-content">
                            <div id="dashboard" class="tab-pane fade show active">
                                <!--                                <h3>Dashboard </h3>-->
                                <p>在您的个人中心，您可以轻松地查看您最近的订单，管理您的送货和帐单地址以及编辑密码和帐户详细信息。</p>
                            </div>
                            <div id="orders" class="tab-pane fade">
                                <h3>订单</h3>
                                <div class="table-responsive">
                                    <table class="table">
                                        <thead>
                                        <tr>
                                            <th>订单序号</th>
                                            <th>日期</th>
                                            <th>产品名称</th>
                                            <!--                                            <th>Status</th>-->
                                            <th>总计</th>
                                            <th>状态</th>
                                        </tr>
                                        </thead>
                                        <tbody id="tbody">
                                        <tr>
                                            <td>1</td>
                                            <td>May 10, 2018</td>
                                            <!--                                            <td>Processing</td>-->
                                            <td>￥25.00</td>
                                            <td><a class="view" href="cart.html">已完成</a></td>
                                        </tr>
                                        <tr>
                                            <td>2</td>
                                            <td>May 10, 2018</td>
                                            <!--                                            <td>Processing</td>-->
                                            <td>￥17.00</td>
                                            <td><a class="view" href="cart.html">已完成</a></td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <jsp:include page="buttom.jsp"/>

</div>



<!-- all plugins JS hear -->
<script src="../grzxjs/popper.min.js"></script>
<script src="../grzxjs/bootstrap.min.js"></script>
<script src="../grzxjs/owl.carousel.min.js"></script>
<script src="../grzxjs/jquery.mainmenu.js"></script>
<script src="../grzxjs/ajax-email.js"></script>
<script src="../grzxjs/plugins.js"></script>
<script type="text/javascript">
    //根据用户id查询订单
    var user = JSON.parse(sessionStorage.getItem("user"));
    function clickQueryOrder() {
        $.ajax({
            type: "GET",
            url: serverUrl + "/order/orderQueryByUserid?psId=" + user.pnId,
            xhrFields: {
                withCredentials: true
            },
            dataType:"json",
            success: function (res) {
                $("#tbody").empty();
                if (res.success) {
                    var resData = res.data;
                    for (var i = 0; i < resData.length; i++) {

                        var item = resData[i];
                        var statusOrder;
                        if (item.osStatus == 0) {
                            statusOrder = "未支付";
                        } else if (item.osStatus == 1) {
                            statusOrder = "已支付";
                        } else if (item.osStatus == 2) {
                            statusOrder = "已发货";
                        } else if (item.osStatus == 3) {
                            statusOrder = "已签收";
                        } else if (item.osStatus == 4) {
                            statusOrder = "已退款";
                        }

                        $("#tbody").append("<tr>\n" +
                            "                                            <td>"+ resData[i].osId +"</td>\n" +
                            "                                            <td>"+ resData[i].osTime +"</td>\n" +
                            "                                            <td>"+ resData[i].product.ptName +"</td>\n" +
                            "                                            <!--                                            <td>Processing</td>-->\n" +
                            "                                            <td> ￥"+ resData[i].product.ptPrice +"</td>\n" +
                            "                                            <td><a class=\"view\" href=\"cart.html\">"+statusOrder+"</a></td>\n" +
                            "                                        </tr>");
                    }
                }
            }
        })
    }


    function pserLogout() {
        sessionStorage.clear();
        window.location.href="user_login.jsp";
    }
</script>

</body>
</html>
